# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=snapper
pkgver=0.11.2
pkgrel=0
pkgdesc="Manage filesystem snapshots and allow undo of system modifications"
url="http://snapper.io"
arch="all"
license="GPL-2.0-or-later"
depends="dbus"
makedepends="
	acl-dev
	autoconf
	automake
	boost-dev
	bsd-compat-headers
	btrfs-progs-dev
	dbus-dev
	docbook-xsl
	e2fsprogs-dev
	gettext-dev
	json-c-dev
	libtool
	libxml2-dev
	libxslt
	lvm2-dev
	ncurses-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/openSUSE/snapper/archive/v$pkgver.tar.gz
	miss-tinfo-link-to-ncurses.patch
	miss-uint-includes.patch
	drift-file-path.patch
	skip-locale-tests.patch
	statvfs64.patch
	"

prepare() {
	default_prepare

	# rename cron scripts
	sed -i -e 's@suse.de-@@g' scripts/Makefile.am
	# copy cron scripts to /etc/periodic/* instead of /etc/cron.*
	sed -i -e 's/cron\./periodic\//g' scripts/Makefile.am
	# fix config location in cron scripts
	sed -i -e 's@/etc/sysconfig/@/etc/snapper/@g' scripts/snapper-hourly
	autoreconf -fvi
}

build() {
	export LDFLAGS="$LDFLAGS -lintl"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--disable-silent-rules \
		--with-conf=/etc/snapper \
		--disable-pam \
		--disable-zypp \
		--disable-ext4 \
		--disable-systemd
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 data/sysconfig.snapper "$pkgdir"/etc/snapper/$pkgname
}

sha512sums="
b418ff91c6ba655edebd600691e2a7c0bc277eb6e327d5c57d0e5b2e008ee859e82a7dc49f2b25003001f0e6e5fc69e611c843231160bbb4626867cfc4cf95e2  snapper-0.11.2.tar.gz
9f03cf2de78407e2b1002f6b9fd644cbe61ef0762c938afcedd620456b8a97e593df3df8f878f06d2caf4297e5125c9be86ea5e43ce9991634bb59cbf3b2831e  miss-tinfo-link-to-ncurses.patch
1a451aca0d94e95995c4ee373b915f5f78bcd17df12370e5e1ed77022be9e98e836e4fa142f81242f67d6ace5444fb89e8eaacd5740c62c051b37017c93c078c  miss-uint-includes.patch
c2470da8a5d62a37babdacd361051bae8fb3e1be157cb7eec1563a40825d41702f6f10bb619ffcab2ea8d7407405a543b0c47997c70a744c20cc3135c0532c1f  drift-file-path.patch
24fdca2d94e4cf551705df7d5332c033fdc2a55f7064d45035fd4d41cbc77544a5a53817f9be751fefadfa3971fc85377d4700eaa32d53222e8c605365890954  skip-locale-tests.patch
dc77db919fc4bd64929e784d09c4a6ed50530b6a88b3a26f4ea341f09e71dbd74e07d1e9fea37f85305d0f251a5c302e1dbb700084d04a16dc2e7687ecc83815  statvfs64.patch
"
